<!DOCTYPE HTML>
<html>
<head>
    <title>Single:: w3layouts</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="css/form.css" rel="stylesheet" type="text/css" media="all"/>
    <link href='http//fonts.googleapis.com/css?family=Exo+2' rel='stylesheet' type='text/css'>
    <script src="js/jquery1.min.js"></script>
    <!-- start menu -->
    <link href="css/megamenu.css" rel="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="js/megamenu.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <script>$(document).ready(function () {
        $(".megamenu").megamenu();
        // 添加头
        $(".header").load("head.html");
        var bookId = $.cookie("bookId");
        $.ajax({
            url: "book/findBookById.do",
            type: "POST",
            data: {id: bookId},
            dataType: "json",
            cache: false,
            success: function (data) {
                //借书人
                var l_username = "无";
                //所属人
                var b_username = "无";
                //获得借书人的名称

                $.ajax({
                    url: "user/getUserById.do",
                    type: "POST",
                    data: {
                        uid: data.lid,
                    },
                    dataType: "json",
                    cache: false,
                    success: function (datall) {
                        l_username = datall.username;
                        //获得图书所属者的名称
                        $.ajax({
                            url: "user/getUserById.do",
                            type: "POST",
                            data: {
                                uid: data.bid,
                            },
                            dataType: "json",
                            cache: false,
                            success: function (datadd) {
                                b_username = datadd.username;
                                var status = null;
                                var values = null;
                                if (data.status == 2) {
                                    status = "发布借出中";
                                    values = "确认借入";
                                }
                                if (data.status == 3) {
                                    status = "发布已借出";
                                    values = "提交归还";
                                }
                                if (data.status == 4) {
                                    status = "发布归还中";
                                }
                                if (values != null) {
                                    var dataStr = "<div class=\"cont span_2_of_3\">\n" +
                                        "                <div class=\"grid images_3_of_2\">\n" +
                                        "                    <div id=\"container\">\n" +
                                        "                        <div id=\"products_example\">\n" +
                                        "                            <div id=\"products\">\n" +
                                        "                                <div >\n" +
                                        "                                    <img  style='height: 500px;width: 500px;' alt='我是一张图片' id=\"img1\" src=\"" + data.image + "\"/>\n" +
                                        "                                </div>\n" +

                                        "                            </div>\n" +
                                        "                        </div>\n" +
                                        "                    </div>\n" +
                                        "                </div>\n" +
                                        "                <div class=\"desc1 span_3_of_2\">\n" +
                                        "                    <p class=\"m_5\">" + data.name + "</p>\n" +
                                        "                    <span class=\"m_link\"><a href=\"#\"></a> </span>\n" +
                                        "                    <p class=\"m_text2\" style='font-size: larger'>书籍简介:</p><p style='width:450px;font-size:medium'>" + data.besc + "</p><hr>\n" +
                                        "                </div>\n" +
                                        "                    <div class=\"btn_form\">\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 图书所属者：" + b_username + "</p>\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 借书人：" + l_username + "</p>\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 图书状态：" + status + "</p><br>\n" +
                                        "                             <input type=\"button\" name=\"Submit\" onclick=\"javascript:history.back(-1);\"\" value=\"返回上一页\"><br><br>\n" +
                                        "                             <input type=\"button\" onclick=\"returnBook('" + data.id + "','" + data.status + "','" + data.name + "')\" value=\"" + values + "\" />\n" +
                                        "                    </div>\n" +
                                        "                <div class=\"clear\"></div>\n" +
                                        "\n" +
                                        "            </div>";
                                } else {
                                    var dataStr = "<div class=\"cont span_2_of_3\">\n" +
                                        "                <div class=\"grid images_3_of_2\">\n" +
                                        "                    <div id=\"container\">\n" +
                                        "                        <div id=\"products_example\">\n" +
                                        "                            <div id=\"products\">\n" +
                                        "                                <div >\n" +
                                        "                                    <img  style='height: 500px; width: 500px;' alt='我是一张图片' id=\"img1\" src=\"" + data.image + "\"/>\n" +
                                        "                                </div>\n" +

                                        "                            </div>\n" +
                                        "                        </div>\n" +
                                        "                    </div>\n" +
                                        "                </div>\n" +
                                        "                <div class=\"desc1 span_3_of_2\">\n" +
                                        "                    <p class=\"m_5\">" + data.name + "</p>\n" +
                                        "                    <span class=\"m_link\"><a href=\"#\"></a> </span>\n" +
                                        "                    <p class=\"m_text2\" style='font-size: larger'>书籍简介:</p><p style='width:450px;font-size:medium'>" + data.besc + "</p><hr>\n" +
                                        "                </div>\n" +
                                        "                    <div class=\"btn_form\">\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 图书所属者：" + b_username + "</p>\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 借书人：" + l_username + "</p>\n" +
                                        "                             <p style='font-size: medium;color: #0b0b0b'> 图书状态：" + status + "</p><br>\n" +
                                        "                             <input type=\"button\" name=\"Submit\" onclick=\"javascript:history.back(-1);\"\" value=\"返回上一页\"><br>\n" +
                                        "                    </div>\n" +
                                        "                <div class=\"clear\"></div>\n" +
                                        "\n" +
                                        "            </div>";
                                }
                                $("#textInfo").append(dataStr);
                            }
                        });
                    }
                });


                // alert(l_username+"  o");
                // alert(b_username+"  o");
                //判断图书状态

            }
        });

    });</script>
    <script type="text/javascript" src="js/jquery.jscrollpane.min.js"></script>
    <script type="text/javascript" id="sourcecode">
        $(function () {
            $('.scroll-pane').jScrollPane();
        });
    </script>
    <script type="text/javascript">
        function returnBook(id, status, bookname) {
            if (status == 2) {
                if (confirm("是否确认已借入？")) {
                    $.ajax({
                        url: "bag/addNotarize.do",
                        type: "POST",
                        data: {
                            bookId: id,
                        },
                        dataType: "json",
                        cache: false,
                        success: function (data) {
                            alert("确认成功");
                            /*确认成功后加入记录*/
                            var uid = null;
                            /*获得session中的对象*/
                            $.ajax({
                                url: "user/getUser.do",
                                type: "POST",
                                data: {},
                                dataType: "json",
                                cache: false,
                                success: function (data) {
                                    if (data != null && (uid = data.id) != null) {
                                        $.ajax({
                                            url: "record/addLoanIn.do",
                                            type: "POST",
                                            data: {
                                                bid:uid,
                                                bookname: bookname,
                                                bookId: id,
                                            },
                                            dataType: "json",
                                            cache: false,
                                            success: function (data) {
                                            }
                                        });
                                    }
                                }
                            });
                            window.location.href = document.referrer;
                        }
                    });
                }
            } else {

                var uid = null;
                /*获得session中的对象*/
                $.ajax({
                    url: "user/getUser.do",
                    type: "POST",
                    data: {},
                    dataType: "json",
                    cache: false,
                    success: function (data) {
                        if (data != null && (uid = data.id) != null) {
                            if (confirm("是否确认归还？")) {
                                $.ajax({
                                    url: "bag/addReturnBook.do",
                                    type: "POST",
                                    data: {
                                        bid: uid,
                                        bookId: id,
                                    },
                                    dataType: "json",
                                    cache: false,
                                    success: function (data) {
                                        alert("提交成功");
                                        window.location.href = document.referrer;
                                    }
                                });
                            }
                        }
                    }
                });

            }
        }
    </script>
    <!-- start details -->
    <script src="js/slides.min.jquery.js"></script>
    <script>
        $(function () {
            $('#products').slides({
                preload: true,
                preloadImage: 'img/loading.gif',
                effect: 'slide, fade',
                crossfade: true,
                slideSpeed: 350,
                fadeSpeed: 500,
                generateNextPrev: true,
                generatePagination: false
            });
        });
    </script>
    <!-- start zoom -->
    <link rel="stylesheet" href="css/zoome-min.css"/>
    <script type="text/javascript" src="js/zoome-e.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#img1,#img2,#img3,#img4').zoome({showZoomState: true, magnifierSize: [250, 250]});
        });
    </script>
</head>
<body>
<div class="header"></div>


<div class="mens">
    <div class="main">
        <div class="wrap">
            <ul class="breadcrumb breadcrumb__t" id="textInfo"></ul>


            <div class="slider-wrapper theme-default">
                <div id="slider" class="nivoSlider">
                    <img src="images/t-img1.jpg" alt=""/>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="footer">
        <div class="footer-bottom">
            <div class="wrap">
                <div class="copy">
                    <p>Copyright &copy; 2014.Company name All rights reserved.<a target="_blank"
                                                                                 href="http//www.zjf88.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a>
                    </p>
                </div>
                <div class="f-list2">
                    <ul>
                        <li class="active"><a href="about.html">关于我们</a></li>
                        |
                        <li><a href="delivery.html">服务条款</a></li>
                        |
                        <li><a href="contact.html">联系我们</a></li>
                    </ul>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
    <div style="display:none">
        <script src='http//v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript'
                charset='gb2312'></script>
    </div>
</body>
</html>